/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ccedeno
 */
@Entity
@Table(name = "expediente", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Expediente.findAll", query = "SELECT e FROM Expediente e"),
    @NamedQuery(name = "Expediente.findAllFecha", query = "SELECT e FROM Expediente e ORDER BY e.fechaReg DESC"),
    @NamedQuery(name = "Expediente.findByCodExp", query = "SELECT e FROM Expediente e WHERE e.codExp = :codExp"),
    @NamedQuery(name = "Expediente.findByFechaReg", query = "SELECT e FROM Expediente e WHERE e.fechaReg = :fechaReg"),
    @NamedQuery(name = "Expediente.findByNumexpeIngr", query = "SELECT e FROM Expediente e WHERE e.numexpeIngr = :numexpeIngr"),
    @NamedQuery(name = "Expediente.findByAsunto", query = "SELECT e FROM Expediente e WHERE e.asunto = :asunto"),
    @NamedQuery(name = "Expediente.findByFolios", query = "SELECT e FROM Expediente e WHERE e.folios = :folios"),
    @NamedQuery(name = "Expediente.findByRemitente", query = "SELECT e FROM Expediente e WHERE e.remitente = :remitente"),
    @NamedQuery(name = "Expediente.findByDetalleExpe", query = "SELECT e FROM Expediente e WHERE e.detalleExpe = :detalleExpe"),
    @NamedQuery(name = "Expediente.findByFkCodificador", query = "SELECT e FROM Expediente e WHERE e.fkCodificador = :fkCodificador"),
    @NamedQuery(name = "Expediente.findByObservac", query = "SELECT e FROM Expediente e WHERE e.observac = :observac"),
    @NamedQuery(name = "Expediente.findByProveido", query = "SELECT e FROM Expediente e WHERE e.proveido = :proveido")})
public class Expediente implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 16)
    @Column(name = "cod_exp", nullable = false, length = 16)
    private String codExp;
    @Column(name = "fecha_reg")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaReg;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "numexpe_ingr", nullable = false, length = 15)
    private String numexpeIngr;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 245)
    @Column(name = "asunto", nullable = false, length = 245)
    private String asunto;
    @Basic(optional = false)
    @NotNull
    @Column(name = "folios", nullable = false)
    private int folios;
    @Size(max = 150)
    @Column(name = "remitente", length = 150)
    private String remitente;
    @Size(max = 255)
    @Column(name = "detalle_expe", length = 255)
    private String detalleExpe;
    @Column(name = "fk_codificador")
    private Integer fkCodificador;
    @Size(max = 120)
    @Column(name = "observac", length = 120)
    private String observac;
    @Size(max = 8)
    @Column(name = "proveido", length = 8)
    private String proveido;
    @JoinColumns({
        @JoinColumn(name = "fk_inter", referencedColumnName = "id_inter", nullable = false),
        @JoinColumn(name = "fk_int_area", referencedColumnName = "id_int_area", nullable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private InteresArea interesArea;
    @JoinColumn(name = "fk_tipo_tramite", referencedColumnName = "id_tipo_tramite", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoTramite tipoTramite;
    @JoinColumn(name = "fk_tipo_docu", referencedColumnName = "cod_tipo_doc", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoDocTra tipoDocTra;
    @JoinColumn(name = "fk_responsable", referencedColumnName = "id_responsable", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Trabajador trabajador;
    @JoinColumn(name = "fk_priori", referencedColumnName = "id_priori", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoPriorida tipoPriorida;
    @JoinColumn(name = "fk_inmuebles", referencedColumnName = "id_inmu")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Inmuebles inmuebles;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "expediente", fetch = FetchType.LAZY)
    private List<MovExp> movExpList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "expediente", fetch = FetchType.LAZY)
    private List<DocAdjunto> docAdjuntoList;

    public Expediente() {
    }

    public Expediente(String codExp) {
        this.codExp = codExp;
    }

    public Expediente(String codExp, String numexpeIngr, String asunto, int folios) {
        this.codExp = codExp;
        this.numexpeIngr = numexpeIngr;
        this.asunto = asunto;
        this.folios = folios;
    }

    public String getCodExp() {
        return codExp;
    }

    public void setCodExp(String codExp) {
        this.codExp = codExp;
    }

    public Date getFechaReg() {
        return fechaReg;
    }

    public void setFechaReg(Date fechaReg) {
        this.fechaReg = fechaReg;
    }

    public String getNumexpeIngr() {
        return numexpeIngr;
    }

    public void setNumexpeIngr(String numexpeIngr) {
        this.numexpeIngr = numexpeIngr;
    }

    public String getAsunto() {
        return asunto;
    }

    public void setAsunto(String asunto) {
        this.asunto = asunto;
    }

    public int getFolios() {
        return folios;
    }

    public void setFolios(int folios) {
        this.folios = folios;
    }

    public String getRemitente() {
        return remitente;
    }

    public void setRemitente(String remitente) {
        this.remitente = remitente;
    }

    public String getDetalleExpe() {
        return detalleExpe;
    }

    public void setDetalleExpe(String detalleExpe) {
        this.detalleExpe = detalleExpe;
    }

    public Integer getFkCodificador() {
        return fkCodificador;
    }

    public void setFkCodificador(Integer fkCodificador) {
        this.fkCodificador = fkCodificador;
    }

    public String getObservac() {
        return observac;
    }

    public void setObservac(String observac) {
        this.observac = observac;
    }

    public String getProveido() {
        return proveido;
    }

    public void setProveido(String proveido) {
        this.proveido = proveido;
    }

    public InteresArea getInteresArea() {
        return interesArea;
    }

    public void setInteresArea(InteresArea interesArea) {
        this.interesArea = interesArea;
    }

    public TipoTramite getTipoTramite() {
        return tipoTramite;
    }

    public void setTipoTramite(TipoTramite tipoTramite) {
        this.tipoTramite = tipoTramite;
    }

    public TipoDocTra getTipoDocTra() {
        return tipoDocTra;
    }

    public void setTipoDocTra(TipoDocTra tipoDocTra) {
        this.tipoDocTra = tipoDocTra;
    }

    public Trabajador getTrabajador() {
        return trabajador;
    }

    public void setTrabajador(Trabajador trabajador) {
        this.trabajador = trabajador;
    }

    public TipoPriorida getTipoPriorida() {
        return tipoPriorida;
    }

    public void setTipoPriorida(TipoPriorida tipoPriorida) {
        this.tipoPriorida = tipoPriorida;
    }

    public Inmuebles getInmuebles() {
        return inmuebles;
    }

    public void setInmuebles(Inmuebles inmuebles) {
        this.inmuebles = inmuebles;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    @XmlTransient
    public List<MovExp> getMovExpList() {
        return movExpList;
    }

    public void setMovExpList(List<MovExp> movExpList) {
        this.movExpList = movExpList;
    }
 
    @XmlTransient
    public List<DocAdjunto> getDocAdjuntoList() {
        return docAdjuntoList;
    }

    public void setDocAdjuntoList(List<DocAdjunto> docAdjuntoList) {
        this.docAdjuntoList = docAdjuntoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codExp != null ? codExp.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Expediente)) {
            return false;
        }
        Expediente other = (Expediente) object;
        if ((this.codExp == null && other.codExp != null) || (this.codExp != null && !this.codExp.equals(other.codExp))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Expediente[ codExp=" + codExp + " ]";
    }
}
